home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / SETXTJFY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1.3 KB  |  45 lines

  1.  
  2. /* setxtjfy.c ---settextjustify --- p 855 */
  3. #include <graphics.h>
  4. main()
  5. {
  6.     int graphdriver=DETECT, graphmode;
  7.     int x, y, th, tw;
  8.     initgraph(&graphdriver, &graphmode, "C:\\TURBOC");
  9.     x = getmaxx()/2;
  10.     y = getmaxy()/2;
  11.             /* Mark the point around which text is justified */
  12.     line(x-100, y, x+100, y);
  13.     line(x, y-100, x, y+100);
  14.             /* Try all justification choices */
  15.     settexstyle(TRIPLEX_FONT, HORIZ_DIR, 8);
  16.     tw = textwidth("A");
  17.     th = textheight("A");
  18.     settextjustify(LEFT_TEXT, TOP_TEXT);
  19.     outtextxy(x, y, "A");
  20.     stetextjustify(LEFT_TEXT, BOTTOM_TEXT);
  21.     outtextxy(x, y, "A");
  22.     settextjustify(RIGHT_TEXT, TOP_TEXT);
  23.     outtextxy(x, y, "A");
  24.     settextjustify(RIGHT_TEXT, BOTTOM_TEXT);
  25.     outtextxy(x, y, "A");
  26.             /* Label the choices */
  27.     settextstyle(SMALL_FONT, HORIZ_DIR, 4);
  28.     settextjustify(LEFT_TEXT, BOTTOM_TEXT);
  29. #define XS (tw+10)
  30. #define YS (th+10)
  31.     moveto(x+XS, y-YS);
  32.     outtext("LEFT_TEXT, BOTTOM_TEXT");
  33.     moveto(x+XS, y+YS);
  34.     settextjustify(LEFT_TEXT, TOP_TEXT);
  35.     outtext("LEFT_TEXT, TOP_TEXT");
  36.     moveto(x-XS, y+YS);
  37.     settextjustify(RIGHT_TEXT, TOP_TEXT);
  38.     outtext("RIGHT_TEXT, TOP_TEXT");
  39.     settextjustify(RIGHT_TEXT, BOTTOM_TEXT);
  40.     moveto(x-XS, y-YS);
  41.     outtext("RIGHT_TEXT, BOTTOM_TEXT");
  42.             /* Wait until user hits a key */
  43.     getch();
  44.     closegraph();
  45. }